@import "common/var";

$light-background: $white;
$light-item-background-hover: $--color-primary-light-9;
$light-item-background-active: $--color-primary;
$light-item-color: $--color-secondary-text;
$light-item-color-hover: $--color-normal-text;
$light-item-color-active: $--color-primary-light-10;
$light-submenu-color-active: $--color-primary-text;
$light-collapsed-color-active: $--color-primary;
$light-item-border-color-active: $--color-primary;
$light-item-horizontal-color-active: $--color-primary;

$primary-background: $--color-primary;
$primary-item-background-hover: mix($--color-primary, $--color-primary-light-6);
$primary-item-background-active: $--color-primary-light-6;
$primary-item-color: $--color-primary-light-9;
$primary-item-color-hover: $--color-primary-light-10;
$primary-item-color-active: $white;
$primary-submenu-color-active: $--color-primary-light-10;
$primary-collapsed-color-active: $white;
$primary-item-border-color-active: $--color-primary-light-10;
$primary-item-horizontal-color-active: $white;

$dark-background: $--color-primary-light-1;
$dark-item-background-hover: $--color-primary-light-2;
$dark-item-background-active: $--color-primary;
$dark-item-color: $--color-primary-light-8;
$dark-item-color-hover: $--color-primary-light-9;
$dark-item-color-active: $--color-primary-light-10;
$dark-submenu-color-active: $--color-primary-light-10;
$dark-collapsed-color-active: $--color-primary-light-10;
$dark-item-border-color-active: $--color-primary-light-10;
$dark-item-horizontal-color-active: $--color-primary-light-10;

$gradual-background: mix($--color-primary-light-1, $--color-primary);
$gradual-item-background-hover: $--color-primary-light-2;
$gradual-item-background-active: $--color-primary;
$gradual-item-color: $--color-primary-light-8;
$gradual-item-color-hover: $--color-primary-light-9;
$gradual-item-color-active: $--color-primary-light-10;
$gradual-submenu-color-active: $--color-primary-light-10;
$gradual-collapsed-color-active: $--color-primary-light-10;
$gradual-item-border-color-active: $--color-primary-light-10;
$gradual-item-horizontal-color-active: $--color-primary-light-10;


@mixin common-item(
  $background,
  $item-background-hover,
  $item-background-active,
  $item-color,
  $item-color-hover,
  $item-color-active,
  $submenu-color-active,
  $collapsed-color-active,
  $item-border-color-active,
  $item-horizontal-color-active
) {
  .el-menu-item-group__title {
    color: $item-color;
    opacity: 0.6;
  }
  li.el-menu-item {
    color: $item-color;

    i {
      color: $item-color;
      transition: font-size 0.3s;
    }

    .el-badge {
      position: relative;
      margin: -4px 0 0 5px;
    }

    .my-icon {
      font-size: 18px;
      margin-left: 5px;
      margin-right: 5px;
      width: 24px;
      text-align: center;
      vertical-align: middle;
    }

    .my-menu__collapsed-icon.el-badge {
      line-height: 0;
      margin: 0;
    }

    &:hover {
      background-color: $item-background-hover;
      color: $item-color-hover;

      i {
        color: $item-color-hover;
      }
    }

    &.is-active {
      background-color: $item-background-active;
      color: $item-color-active;

      i {
        color: $item-color-active;
      }
    }
  }

  .el-submenu {
    > .el-submenu__title {
      color: $item-color;

      i {
        color: $item-color;
        transition: font-size 0.3s;
      }

      .my-icon {
        font-size: 18px;
        margin-left: 5px;
        margin-right: 5px;
        width: 24px;
        text-align: center;
        vertical-align: middle;
      }

      .el-badge {
        position: relative;
        margin: -4px 0 0 5px;
      }

      .my-menu__collapsed-icon.el-badge {
        line-height: 0;
        margin: 0;
      }

      &:hover {
        background-color: $item-background-hover;
        color: $item-color-hover;

        i {
          color: $item-color-hover;
        }
      }
    }

    &.is-active {
      > .el-submenu__title {
        color: $submenu-color-active;

        i {
          color: $submenu-color-active;
        }
      }
    }
  }
}

@mixin theme-builder(
  $background,
  $item-background-hover,
  $item-background-active,
  $item-color,
  $item-color-hover,
  $item-color-active,
  $submenu-color-active,
  $collapsed-color-active,
  $item-border-color-active,
  $item-horizontal-color-active
) {
  &.my-menu {
    background-color: $background;

    @include common-item(
                    $background,
                    $item-background-hover,
                    $item-background-active,
                    $item-color,
                    $item-color-hover,
                    $item-color-active,
                    $submenu-color-active,
                    $collapsed-color-active,
                    $item-border-color-active,
                    $item-horizontal-color-active
    );

    &.el-menu--collapse {
      .el-menu-item .my-icon, .el-submenu > .el-submenu__title .my-icon {
        font-size: 24px;
        margin-left: 0;
      }

      .el-submenu.is-active > .el-submenu__title i {
        color: $collapsed-color-active
      }
    }

    &:not(.el-menu--horizontal) {
      .el-menu-item, .el-submenu > .el-submenu__title {
        height: 50px;
        line-height: 50px;
      }

      .el-submenu .el-menu-item {
        height: 45px;
        line-height: 44px;
      }
    }

    &.el-menu--horizontal {
      > .el-menu-item {
        &.is-active {
          background-color: transparent;
          color: $item-horizontal-color-active;
          border-bottom: 4px solid $item-border-color-active;

          i {
            color: $item-horizontal-color-active;
          }
        }
      }

      > .el-submenu.is-active {
        > .el-submenu__title {
          color: $item-horizontal-color-active;
          border-bottom: 4px solid $item-border-color-active;

          i {
            color: $item-horizontal-color-active;
          }
        }
      }
    }
  }

  &.my-menu--popup {
    .el-menu--popup {
      @include common-item(
                      $background,
                      $item-background-hover,
                      $item-background-active,
                      $item-color,
                      $item-color-hover,
                      $item-color-active,
                      $submenu-color-active,
                      $collapsed-color-active,
                      $item-border-color-active,
                      $item-horizontal-color-active
      );
    }

    .el-menu {
      background-color: transparent;
    }

    .el-menu--popup {
      background-color: $background;

      .el-menu-item, .el-submenu > .el-submenu__title {
        height: 45px;
        line-height: 44px;
        background-color: transparent;
        color: $item-color;

        .my-icon {
          margin-right: 5px;
        }
      }
    }

    .el-submenu.is-active {
      .el-submenu__title {
        color: $collapsed-color-active;

        i {
          color: $collapsed-color-active;
        }
      }
    }


    .el-menu-item-group__title {
      color: $item-color;
      opacity: 0.6;
    }
  }
}

@include b(menu) {
  &.el-menu {
    border-right: none !important;
    border-bottom: none !important;
  }
  &:not(.el-menu--collapse) {
    width: 100%;
  }

  .el-menu {
    background-color: transparent;
  }
}


@include when(light) {
  @include theme-builder(
                  $light-background,
                  $light-item-background-hover,
                  $light-item-background-active,
                  $light-item-color,
                  $light-item-color-hover,
                  $light-item-color-active,
                  $light-submenu-color-active,
                  $light-collapsed-color-active,
                  $light-item-border-color-active,
                  $light-item-horizontal-color-active
  )
}

@include when(primary) {
  @include theme-builder(
                  $primary-background,
                  $primary-item-background-hover,
                  $primary-item-background-active,
                  $primary-item-color,
                  $primary-item-color-hover,
                  $primary-item-color-active,
                  $primary-submenu-color-active,
                  $primary-collapsed-color-active,
                  $primary-item-border-color-active,
                  $primary-item-horizontal-color-active
  )
}


@include when(dark) {
  @include theme-builder(
                  $dark-background,
                  $dark-item-background-hover,
                  $dark-item-background-active,
                  $dark-item-color,
                  $dark-item-color-hover,
                  $dark-item-color-active,
                  $dark-submenu-color-active,
                  $dark-collapsed-color-active,
                  $dark-item-border-color-active,
                  $dark-item-horizontal-color-active
  )
}

@include when(gradual) {
  @include theme-builder(
                  $gradual-background,
                  $gradual-item-background-hover,
                  $gradual-item-background-active,
                  $gradual-item-color,
                  $gradual-item-color-hover,
                  $gradual-item-color-active,
                  $gradual-submenu-color-active,
                  $gradual-collapsed-color-active,
                  $gradual-item-border-color-active,
                  $gradual-item-horizontal-color-active
  )
}


.el-tooltip__popper .el-badge {
  margin-left: 5px;
}


